<!DOCTYPE html>
<html>
<head>
    <title>E8NET</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <include file="./App/Admin/View/Include/css.html" />
    <link href="__PUBLIC__/Admin/css/lib/select2.css" type="text/css" rel="stylesheet" />
    <link rel="stylesheet" href="__PUBLIC__/Admin/css/compiled/form-showcase.css" type="text/css" media="screen" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

<include file="./App/Admin/View/Include/navbar.html" />
<include file="./App/Admin/View/Include/menu.html" />

<!-- main container -->
<div class="content">


    <div role="breadcrumb">
        <ol class="breadcrumb">
            <li><a href="{:U('Paper/index')}">试卷管理</a> / </li>
            <li class="active">添加试卷</li>
        </ol>
    </div>

    <div class="container-fluid">

        <div id="pad-wrapper" class="form-page">
            <div class="row-fluid form-wrapper">
                <!-- left column -->
                <div class="span6 column offset3">
                    <form id="sadmin-form" />
                    <div class="field-box">
                        <label>试卷名称</label>
                        <input class="span8 inline-input" id = "t_name" name="name" placeholder="请输入试卷名称" type="text" />
                        <br>
                                <span id="msg" style="display: none; color:darkred">
                                    <i class="icon-remove-sign"></i>
                                    <small></small>
                                </span>

                    </div>
                    <div class="field-box">
                        <label>排序ID</label>
                        <input class="span8 inline-input" id = "sort_id" name="name" placeholder="请输入排序ID名称" type="text" />

                                <span id="st" style="display: none; color:darkred">
                                    <i class="icon-remove-sign"></i>
                                    <small></small>
                                </span>

                    </div>


                    <div class="span6 field-box actions" style="padding-left:360px;">

                        <a href="javascript:add();" class="btn-flat default">
                            提交表单
                        </a>
                        <a href="{:U('index')}" class="btn-flat gray">
                            放弃提交
                        </a>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- end main container -->

<include file="./App/Admin/View/Include/js.html" />
<script src="__PUBLIC__/Admin/js/jquery-latest.js"></script>
<script src="__PUBLIC__/Admin/js/js/bootstrap.min.js"></script>
<script src="__PUBLIC__/Admin/js/jquery.uniform.min.js"></script>
<script src="__PUBLIC__/Admin/js/select2.min.js"></script>

<script type="text/javascript">


    $(function () {
        $("#update").hide();
        // add uniform plugin styles to html elements
        $("input:checkbox, input:radio").uniform();
        // select2 plugin for select elements
        $(".select2").select2({
            placeholder: "Select a State"
        });
        // datepicker plugin
        $('.datepicker').datepicker().on('changeDate', function (ev) {
            $(this).datepicker('hide');
        });
        // wysihtml5 plugin on textarea
        $(".wysihtml5").wysihtml5({
            "font-styles": false
        });
    });

    function add() {
        var name = $('#t_name').val();
        var s_id = $('#sort_id').val();
        if (name == ""|| s_id == ""){
            $('#msg >small').html('试卷不能为空!');
            $('#st >small').html('排序ID不能为空!');
            $('#msg').show();
            return;
        }
        $.post('__APP__/Paper/add',{name:name,sort:s_id}, function (result) {
            var obj = eval('('+result+')');
            if (obj.result == "RESULT_OK"){
                window.location.href = obj.data;
            }else{
                $('#msg > small').html(obj.msg);
                $('#msg').show();
            }

        });

    }
</script>


</body>
</html>